//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    motto: 'Hello World..你妈蛋',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    headImgs:[
      "https://b1-q.mafengwo.net/s1/M00/AD/DC/wKgBm07TMrHAA9IYAAGGhrdu9zg40.jpeg?imageView2%2F2%2Fw%2F600%2Fq%2F90",
      "https://b1-q.mafengwo.net/s1/M00/AE/01/wKgBm07TM5u8mbe9AAIFiTcvWuc87.jpeg?imageView2%2F2%2Fw%2F600%2Fq%2F90",
      "https://a2-q.mafengwo.net/s1/M00/AE/1A/wKgBm07TNB6IgU-ZAALbARfgtyo06.jpeg?imageView2%2F2%2Fw%2F600%2Fq%2F90",
      "https://n3-q.mafengwo.net/s2/M00/33/17/wKgBpU7TND7N72jcAAKHaZdgum019.jpeg?imageView2%2F2%2Fw%2F600%2Fq%2F90"
    ],
    funcImgs:[
      "http://img.qq1234.org/uploads/allimg/150403/1F14a529-0.jpg",
      "http://img.qq1234.org/uploads/allimg/150403/1F149AL-1.jpg",
      "http://img.qq1234.org/uploads/allimg/150403/1F1493A1-2.jpg",
      "http://img.qq1234.org/uploads/allimg/150403/1F1494305-5.jpg"
    ],
    indicatorDots: false,
    autoplay: true,
    interval: 3000,
    duration: 1000,
    longitude: 120.217840,
    latitude:30.185680,
    scale:16,
    markers: [{
        iconPath: "/resources/locate.png",
        id: 1,
        latitude: 30.185680,
        longitude: 120.217840,
        width: 20,
        height: 20,
        title: "杭州棕熊软件科技有限公司",
    }],
    companyName:"公司名称：杭州棕熊软件科技有限公司",
    companyTell: "公司电话：13675815280",
    companyEmail: "公司邮箱：market@brownbearsoft.com‍",
    companyAddr: "公司地址：杭州市滨江区江陵路567号新东方国际科技中心909",
  },
  //事件处理函数
  bindViewTap: function() {
    // wx.navigateTo({
    //   url: '../logs/logs'
    // })
  },
  onLoad: function () {
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else if (this.data.canIUse){
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },

  funcTap:function(){
    // wx.showToast({
    //   title: "你点了",
    //   icon: '',
    //   image: '',
    //   duration: 1000,
    //   mask: true,
    //   success: function(res) {},
    //   fail: function(res) {},
    //   complete: function(res) {},
    // })
  },

  gotoCompany:function(){
    wx.navigateTo({
      url: '../company/company'
    })
  },

  gotoExample: function () {
      wx.navigateTo({
          url: '../example/example'
      })
  },

  reqInfo:function(){
      wx.request({
          url: "https://qij4h5.natappfree.cc/article/push.php",
          
        //   header:{
        //       "content-type":"application/json"
        //   },
        //   success:function(res){
        //       console.log(res.data)
        //   },
        //   fail:function(res){
        //       console.log(res.data)
        //   }
      })
  }
})
